﻿<UserControl x:Class="GTServices.WPF.Client.Views.CreateBugView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:cont="clr-namespace:GTServices.WPF.Client.Controls"
             xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro"
             mc:Ignorable="d" 
             d:DesignHeight="700" d:DesignWidth="1200">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="50*" />
            <RowDefinition Height="3" />
            <RowDefinition Height="50*" />
        </Grid.RowDefinitions>
        <DockPanel Grid.Row="0">
            <ListView DockPanel.Dock="Left" ItemsSource="{Binding Bug.MatchInfos}">
                <ListView.View>
                    <GridView>
                        <GridViewColumn Header="Pattern" DisplayMemberBinding="{Binding Pattern.PatternStr}" />
                        <GridViewColumn Header="Filename" DisplayMemberBinding="{Binding FileInfo.Name}" />
                        <GridViewColumn Header="Line#" DisplayMemberBinding="{Binding LineNumber}" />
                    </GridView>
                </ListView.View>
                <ListView.ItemContainerStyle>
                    <Style TargetType="{x:Type ListViewItem}">
                        <Setter Property="ToolTip" Value="{Binding Line}" />
                    </Style>
                </ListView.ItemContainerStyle>
            </ListView>
            <TabControl  DockPanel.Dock="Right">
                <TabItem Header="Category">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="50*" />
                            <ColumnDefinition Width="4" />
                            <ColumnDefinition Width="50*" />
                        </Grid.ColumnDefinitions>
                        <DockPanel Grid.Column="0" DockPanel.Dock="Left">
                            <StackPanel>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>
                                    <Label Grid.Column="0" Content="Category: " />
                                    <ComboBox Grid.Column="1" SelectedItem="{Binding SelectedCategory}" ItemsSource="{Binding Categories}" DisplayMemberPath="Name" />
                                </Grid>


                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>
                                    <Label Grid.Column="0" Content="Sev: " />
                                    <Label Grid.Column="1" Content="{Binding SelectedCategory.Severity}" />
                                </Grid>
                                    
                                    
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>
                                    <Label Grid.Column="0" Content="Classification: " />
                                    <TextBox Grid.Column="1" DockPanel.Dock="Left" IsReadOnly="True" Text="{Binding SelectedCategory.Classification.Name}" />
                                    <cont:ClickableLabel Grid.Column="2" DockPanel.Dock="Right" Text="Select"  cal:Message.Attach="[Event Click]  =  [Action SelectCategoryClassification]" />
                                </Grid>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>
                                    <Label Grid.Column="0" Content="Template: " />
                                    <TextBox Grid.Column="1" DockPanel.Dock="Left" IsReadOnly="True" Text="{Binding SelectedCategory.Template.Name}" />
                                    <cont:ClickableLabel Grid.Column="2" DockPanel.Dock="Right" Text="Select"  cal:Message.Attach="[Event Click]  =  [Action SelectCategoryTemplate]" />
                                </Grid>
                            </StackPanel>
                        </DockPanel>
                        <GridSplitter Grid.Column="1" Width="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
                        <DockPanel Grid.Column="2" DockPanel.Dock="Right">
                            <TabControl>
                                <TabControl.Resources>
                                    <Style TargetType="TextBox">
                                        <Setter Property="AcceptsReturn" Value="True" /> 
                                    </Style>
                                </TabControl.Resources>
                                <TabItem Header="Description">
                                    <TextBox AcceptsReturn="True" TextWrapping="Wrap" Text="{Binding SelectedCategory.Description}" />
                                </TabItem>
                                <TabItem Header="Exploit Scenario">
                                    <TextBox AcceptsReturn="True" TextWrapping="Wrap" Text="{Binding SelectedCategory.ExploitScenario}" />
                                </TabItem>
                                <TabItem Header="Recommendation">
                                    <TextBox AcceptsReturn="True" TextWrapping="Wrap" Text="{Binding SelectedCategory.Recommendation}" />
                                </TabItem>
                                <TabItem Header="References">
                                    <TextBox AcceptsReturn="True" 
                                             TextWrapping="Wrap" 
                                             Text="{Binding SelectedCategory.References}"
                                             
                                             />
                                </TabItem>
                            </TabControl>
                        </DockPanel>

                    </Grid>
                </TabItem>
                <TabItem Header="Template">
                    <DockPanel>
                        <StackPanel  DockPanel.Dock="Top" >
                            <StackPanel Orientation="Horizontal">
                                <Label Content="Template: " DockPanel.Dock="Left" />
                                <TextBox IsReadOnly="True" Text="{Binding Template.Name}" />
                                <cont:ClickableLabel Text="Select" cal:Message.Attach="[Event Click]  =  [Action SelectTemplate]" />
                            </StackPanel>
                        </StackPanel>
                        <TextBox DockPanel.Dock="Right" AcceptsReturn="True" Text="{Binding Template.RawTemplate}" />
                    </DockPanel>
                       
                </TabItem>
            </TabControl>
        </DockPanel>
        <GridSplitter Grid.Row="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
        <DockPanel Grid.Row="2" LastChildFill="True">
            <TextBox AcceptsReturn="True" DockPanel.Dock="Bottom" Text="{Binding TemplateText}" />
        </DockPanel>
    </Grid>
</UserControl>
